package model.inventory;

import java.util.List;

import model.Container;
import model.contents.Content;

public class InventoryRotator {
	private Container mainImageContainer;
	private List<Content> contents;
	private int position;
	public InventoryRotator(Container mainImageContainer, List<Content> contents) {
		this.mainImageContainer = mainImageContainer;
		this.contents = contents;
		this.position = 0;
	}
	
	public void rotate() {
		if(mainImageContainer!=null ) {
			mainImageContainer.setContent(this.contents.get(this.position));
		}
		this.position = (this.position+1)%contents.size();
	}

	public boolean canRotate() {
		return this.contents.get(this.position)!=null && this.contents.get(this.position).isValidContent();
	}
	
	
	
	public int getPosition() {
		return this.position;
	}
	
	public int getNumberRotations() {
		return this.contents.size();
	}

	public Content getContent(int i) {
		if(this.contents.size()>0) {
			return this.contents.get(0);
		}
		return null;
	}
	
	public String toString() {
		return "Total number of rotations: " + this.getNumberRotations() + ", index: " + this.getPosition();
	}
}